package com.kejiguan.ui.response;

import com.android.volley.cache.Cache;
import com.google.gson.annotations.Expose;
import com.kejiguan.ui.model.ExhibitionNeItem;
import com.kejiguan.ui.util.CacheDataUtil;
import com.kejiguan.ui.util.CommonDate;

import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * Created by apple on 16/4/21.
 */
public class CheckNeItemsStateResponse extends BaseResponse{


    @Expose
    private Map<String,List<ExhibitionNeItem>> exhibitionRecordMap;

    public Map<String, List<ExhibitionNeItem>> getExhibitionRecordMap() {
        return exhibitionRecordMap;
    }

    public void setExhibitionRecordMap(Map<String, List<ExhibitionNeItem>> exhibitionRecordMap) {
        this.exhibitionRecordMap = exhibitionRecordMap;
    }

    public void countRunnningData()
    {
        if (null!=exhibitionRecordMap)
        {
            int totalCount=0;
            int totalRunningCount=0;
            int totalexitCount=0;

            Set<String> keys=exhibitionRecordMap.keySet();
            Iterator<String> stringIterator=keys.iterator();
            while (stringIterator.hasNext())
            {
                String key=stringIterator.next();
                List<ExhibitionNeItem> exhibitionNeItems=exhibitionRecordMap.get(key);
                totalCount+=exhibitionNeItems.size();

                for (ExhibitionNeItem exhibitionNeItem:exhibitionNeItems)
                {
                    if (CommonDate.STATE_RUNNING.equals(exhibitionNeItem.getExhibitionState()))
                    {
                        totalRunningCount+=1;
                    }else if (CommonDate.STATE_EXIT.equals(exhibitionNeItem.getExhibitionState()))
                    {
                        totalexitCount+=1;
                    }
                }
            }

            CacheDataUtil.getInstance().setTotalCount(totalCount);
            CacheDataUtil.getInstance().setTotalRunningCount(totalRunningCount);
            CacheDataUtil.getInstance().setTotalexitCount(totalexitCount);
        }
    }
}
